package org.dromara.common.core.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum CommonAuditStatusEnum {
    WAITING(0, "待审核"),
    PASS(1, "审核通过"),
    REFUSE(2, "审核拒绝");

    private final Integer status;
    private final String desc;

    public static void checkBackStatus(Integer status) {
        if (WAITING.status.equals(status)) {
            throw new RuntimeException("已退回状态不能退回");
        }
    }

    public static void checkCancelStatus(Integer status) {
        if (WAITING.status.equals(status)) {
            throw new RuntimeException("已退回状态不能取消");
        }
    }

    public static void checkInvalidStatus(Integer status) {
        if (WAITING.status.equals(status)) {
            throw new RuntimeException("已退回状态不能作废");
        }
    }

    public static void checkStartStatus(Integer status) {
        if (PASS.status.equals(status)) {
            throw new RuntimeException("已通过状态不能发起");
        }
    }

    public static String findByStatus(Integer status) {
        for (CommonAuditStatusEnum value : values()) {
            if (value.status.equals(status)) {
                return value.desc;
            }
        }
        return null;
    }
}
